﻿using Microsoft.ProjectOxford.Common.Contract;
using Microsoft.ProjectOxford.Face.Controls;
using System.Drawing;
using System.Windows.Forms;
using view.Model;

namespace view.ComControl
{
    public partial class FaceResultCtl : UserControl
    {
        /// <summary>
        /// 人脸信息
        /// </summary>
        private FaceInfo _faceInfo;

        /// <summary>
        /// 微软认知服务人脸识别返回的信息
        /// </summary>
        public FaceInfo FaceInfo
        {
            set
            {
                _faceInfo = value;
                // 年龄
                this.txtAzureAge.Text = value.Age;
                // 情感
                this.txtAzureEmotion.Text = value.Emotion;
                // 头发
                this.txtAzureFacialHair.Text = value.FacialHair;
                // 性别
                this.txtAzureGender.Text = value.Gender;
                // 眼睛
                this.txtAzureGlasses.Text = value.Glasses;
                // 人ID
                this.txtPersonId.Text = value.PersonId;
                // 人名
                this.txtPersonName.Text = value.PersonName;
                // 人脸ID
                this.txtFaceId.Text = value.FaceId;
                // 人脸图片
                if (!string.IsNullOrEmpty(value.FaceImgname))
                {
                    this.imgFace.Image = Image.FromFile(value.FaceImgname);
                }
            }
            get
            {
                return _faceInfo;
            }
        }

        /// <summary>
        /// 设置本地人脸信息
        /// </summary>
        public EmployeeInfo EmployeeInfo
        {
            set
            {
                // 年龄
                this.txtLocalBirthday.Text = value.Birthday;
                // 部门名称
                this.txtLocalDeptName.Text = value.DeptName;
                // 邮箱
                this.txtLocalEmail.Text = value.Email;
                // 爱好
                this.txtLocalHobby.Text = value.Hobby;
                // 电话
                this.txtLocalMobile.Text = value.Mobile;
                // 姓名
                this.txtLocalName.Text = value.Name;
                // 国籍
                this.txtLocalNationality.Text = value.Nationality;
                // 职位
                this.txtLocalPosition.Text = value.Position;
                // 性别
                this.txtLocalSexMale.Text = value.Gender;
            }
        }

        /// <summary>
        /// 设置情感API信息
        /// </summary>
        public EmotionScores EmotionScores
        {
            set
            {
                // 愤怒指数
                this.txtAnger.Text = value.Anger.ToString();
                // 鄙视指数
                this.txtContempt.Text = value.Contempt.ToString();
                // 厌恶指数
                this.txtDisgust.Text = value.Disgust.ToString();
                // 恐惧指数 
                this.txtFear.Text = value.Fear.ToString();
                // 幸福指数 
                this.txtHappiness.Text = value.Happiness.ToString();
                // 中立指数 
                this.txtNeutral.Text = value.Neutral.ToString();
                // 悲伤指数
                this.txtSadness.Text = value.Sadness.ToString();
                // 惊讶指数 
                this.txtSurprise.Text = value.Surprise.ToString();
            }
        }

        /// <summary>
        /// 获得语音播报内容
        /// </summary>
        public string SpeekInfo
        {
            get
            {
                if ("male".Equals(_faceInfo.Gender))
                {
                    return this.txtLocalName.Text + "先生";
                }
                else
                {
                    return this.txtLocalName.Text + "女士";
                }
            }
        }

        public FaceResultCtl()
        {
            InitializeComponent();
        }
    }
}
